package org.example.mapper;

import org.apache.ibatis.annotations.*;
import org.example.entity.Student;

import java.util.List;

@Mapper// springboot 整合mybatis,需要在mapper接口上添加@Mapper注解,否则接口不能有效识别
// dao,持久层,用mapper替代
public interface StudentMapper {

    @Insert("insert into student(id,name,age) values (#{id},#{name},#{age})")
    void insert(Student student);

    @Update("update student set name=#{name},age=#{age} where id=#{id}")
    void update(Student student);

    @Delete("delete from student where id=#{id}")
    void delete(String id);

    @Select("select * from student")
    List<Student> getAll();

    @Select("select * from student where id =#{id}")
    Student getById(String id);

}
